﻿package mortal.game.view.copy.treasureHunt
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.manager.*;
    import com.mui.utils.*;
    import extend.language.*;
    import fl.data.*;
    import flash.display.*;
    import flash.events.*;
    import mortal.common.display.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.component.windowTip.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.treasureHunt.renderer.*;
    import mortal.game.view.vip.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class TreasureHuntEnterWinNew extends ActivityBaseWindow
    {
        private var _btnDetailPlay:GButton;
        private var _rewardItemList:GTileList;
        private var _silverSpr:ToolTipSprite;
        private var _goldSpr:ToolTipSprite;
        private var _zijinSpr:ToolTipSprite;
        private var _bmp1:GBitmap;
        private var _bmp2:GBitmap;
        private var _bmp3:GBitmap;
        private var _isAddArrow:Boolean;
        private static var _instance:TreasureHuntEnterWinNew;

        public function TreasureHuntEnterWinNew(param1:ILayer = null, param2:String = "", param3:String = "")
        {
            setSize(696, 412);
            super(param1, ImagesConst.TreasureHuntTitle, ImagesConst.TreasureHuntBgNew);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._silverSpr = UICompomentPool.getUICompoment(ToolTipSprite);
            this._silverSpr.x = 100;
            this._silverSpr.y = 180;
            this.addChild(this._silverSpr);
            this._silverSpr.toolTipData = Language.getString(40950);
            this._silverSpr.reactionTime = 200;
            this._bmp1 = UIFactory.gBitmap(BitmapDataConst.AlphaBMD, 0, 0, this._silverSpr);
            this._bmp1.width = 106;
            this._bmp1.height = 95;
            var _loc_1:* = VipUtil.getVipMinLevelByType(EVipRecordType._EVipRecordTypeRaiderReward);
            this._goldSpr = UICompomentPool.getUICompoment(ToolTipSprite);
            this._goldSpr.x = 488;
            this._goldSpr.y = 180;
            this.addChild(this._goldSpr);
            this._goldSpr.toolTipData = Language.getString(40951);
            this._goldSpr.reactionTime = 200;
            this._bmp2 = UIFactory.gBitmap(BitmapDataConst.AlphaBMD, 0, 0, this._goldSpr);
            this._bmp2.width = 106;
            this._bmp2.height = 95;
            this._zijinSpr = UICompomentPool.getUICompoment(ToolTipSprite);
            this._zijinSpr.x = 288;
            this._zijinSpr.y = 109;
            this.addChild(this._zijinSpr);
            this._zijinSpr.toolTipData = Language.getString(40952);
            this._zijinSpr.reactionTime = 200;
            this._bmp3 = UIFactory.gBitmap(BitmapDataConst.AlphaBMD, 0, 0, this._zijinSpr);
            this._bmp3.width = 127;
            this._bmp3.height = 118;
            this._rewardItemList = UIFactory.tileList(177, 342 - 29, 275, 45, this.contentTopOf3DSprite);
            this._rewardItemList.columnWidth = 44;
            this._rewardItemList.rowHeight = 43;
            this._rewardItemList.horizontalGap = 0;
            this._rewardItemList.verticalGap = 0;
            this._rewardItemList.setStyle("skin", new Bitmap());
            this._rewardItemList.setStyle("cellRenderer", TreasureRewardItemCellRenderer);
            this._btnDetailPlay = UIFactory.gButton(Language.getString(40949), 537, 356 - 33, 65, 22, this.contentTopOf3DSprite, "GreenLinkButton");
            this._btnDetailPlay.configEventListener(MouseEvent.CLICK, this.onClickDetailPlay);
            pushUIToDisposeVec(UIFactory.gTextField(Language.getString(40953), 97 - 3 + 188, 400 - 30 - 13, 200, 22, this, GlobalStyle.textFormatHuang2.setSize(13)));
            this.initItemList();
            return;
        }// end function

        private function initItemList() : void
        {
            var _loc_1:Array = [];
            var _loc_2:* = CopyConfig.instance.getCopyInfoByCode(305);
            if (_loc_2 && _loc_2.rewardShow)
            {
                _loc_1 = _loc_2.rewardShow.split("#");
            }
            var _loc_3:Array = [];
            var _loc_4:int = 0;
            while (_loc_4 < _loc_1.length)
            {
                
                _loc_3.push(new ItemData(int(_loc_1[_loc_4])));
                _loc_4++;
            }
            var _loc_5:* = new DataProvider();
            _loc_5.addItems(_loc_3);
            this._rewardItemList.dataProvider = _loc_5;
            this._rewardItemList.drawNow();
            this._rewardItemList.x = (this.width - this._rewardItemList.columnWidth * this._rewardItemList.length) / 2 + 2;
            return;
        }// end function

        override protected function onClickEnterBtn(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.TreasureHuntEnterCopy));
            return;
        }// end function

        private function onClickDetailPlay(event:MouseEvent) : void
        {
            var _loc_2:* = new WindowTipData();
            _loc_2.type = WindowTipType.TreasureHunt_Detail;
            _loc_2.tip = Language.getString(40708);
            _loc_2.title = Language.getString(40949);
            _loc_2.tipW = 500;
            _loc_2.tipH = 500;
            WindowTipManager.showTip(_loc_2);
            return;
        }// end function

        override public function hide() : void
        {
            super.hide();
            WindowTipManager.hideTip(WindowTipType.TreasureHunt_Detail);
            return;
        }// end function

        private function onTakeRewardHandler(event:MouseEvent) : void
        {
            GameProxy.player.getVipReWard(Cache.instance.vip.level, EVipRecordType._EVipRecordTypeRaiderReward, this.onTakeSuccHandler);
            return;
        }// end function

        private function onTakeSuccHandler() : void
        {
            return;
        }// end function

        private function updateTakeState() : void
        {
            return;
        }// end function

        private function updateVipAddvalue() : void
        {
            var _loc_3:int = 0;
            var _loc_5:int = 0;
            var _loc_1:* = Cache.instance.vip.level;
            var _loc_2:* = VipUtil.getVipMinLevelByType(EVipRecordType._EVipRecordTypeRaiderReward);
            if (_loc_1 < _loc_2)
            {
                _loc_3 = _loc_2;
            }
            else
            {
                _loc_3 = _loc_1;
            }
            var _loc_4:* = VipConfig.instance.getValueByTypeAndLv(EVipRecordType._EVipRecordTypeRaiderReward, _loc_3);
            if (_loc_4)
            {
                _loc_5 = int(_loc_4.split("#")[1]);
            }
            return;
        }// end function

        private function addArrow() : void
        {
            return;
        }// end function

        private function removeArrow() : void
        {
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._btnDetailPlay.dispose(param1);
            this._btnDetailPlay = null;
            this._rewardItemList.dispose();
            this._rewardItemList = null;
            this._silverSpr.dispose();
            this._silverSpr = null;
            this._goldSpr.dispose();
            this._goldSpr = null;
            this._zijinSpr.dispose();
            this._zijinSpr = null;
            this._bmp1.dispose();
            this._bmp1 = null;
            this._bmp2.dispose();
            this._bmp2 = null;
            this._bmp3.dispose();
            this._bmp3 = null;
            this._isAddArrow = false;
            return;
        }// end function

        public static function get instance() : TreasureHuntEnterWinNew
        {
            if (!_instance)
            {
                _instance = new TreasureHuntEnterWinNew;
            }
            return _instance;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

    }
}
